package com.nfIt.sumThread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * ClossName:MainTest2
 * Pakage:com.nfIt.sumThread
 * Description
 *
 * @Author L
 * @Create 2024/3/20 9:08
 * @Version 2023.1.3
 */
public class MainTest2 {
    public static void main(String[] args) throws Exception {
        SumCallThread sumCallThread1 = new SumCallThread(1,100);
        SumCallThread sumCallThread2 = new SumCallThread(101,900);
        SumCallThread sumCallThread3 = new SumCallThread(901,1000);


        FutureTask<Integer> futureTask1 = new FutureTask(sumCallThread1);
        FutureTask<Integer>  futureTask2 = new FutureTask(sumCallThread2);
        FutureTask<Integer>  futureTask3 = new FutureTask(sumCallThread3);

        Thread thread1 = new Thread(futureTask1);
        Thread thread2 = new Thread(futureTask2);
        Thread thread3 = new Thread(futureTask3);

        thread1.start();
        thread2.start();
        thread3.start();

        Integer sum = futureTask1.get()+futureTask2.get()+futureTask3.get();
        System.out.println(sum);

    }
}
